<?php 
namespace Common\Service;
use Common\Util\HttpUtil;
use Common\Util\CacheUtils;
use Common\Util\ConfigUtils;

/**
 * 小程序接口
 * @author liuyang 
 * V1.0
 */
class WeixinLiteService {
	   
	
	private static function _setCache($key,$val,$expire){
	    CacheUtils::set($key,$val,$expire);
	}
	
	private static function _getCache($key){
	    return CacheUtils::get($key); 
	}
	
	public static function getKey(){
		return ConfigUtils::getConfig("WEIXIN_LITE_APPID");
	}
	public static function getSecret(){
	    return ConfigUtils::getConfig("WEIXIN_LITE_SECRET");
	}
	 
	/**
	 * 拿到认证环
	 * @return Ambigous <mixed, unknown>
	 */
	public  static function obtainLoginInfo($code){ 
			$url="https://api.weixin.qq.com/sns/jscode2session?grant_type=authorization_code&js_code=".$code
			     ."&appid=".self::getKey()."&secret=".self::getSecret();
			$rstdata = json_decode(HttpUtil::curlGet($url),true);   
		    return $rstdata;
	}
	
	
	 
	 
}